package org.dromara.resource.api.feign;

import org.dromara.common.core.domain.R;
import org.dromara.resource.api.feign.fallback.ResourceMessageFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

import static org.dromara.common.core.constant.ServerNameConstants.RESOURCE_SERVER_NAME;

/**
 * @author: zhou shuai
 * @date: 2024/10/5 15:35
 * @version: v1
 */
@FeignClient(contextId = "resource-message-api", name = RESOURCE_SERVER_NAME, fallbackFactory = ResourceMessageFallBack.class)
public interface ResourceMessageClient {

    /**
     * 发送消息
     *
     * @param sessionKeyList session主键 一般为用户id
     * @param message    消息文本
     */
    @PostMapping(value = "/api/resource/message/publish")
    R<Void> publishMessage(@RequestParam("sessionKeyList") List<Long> sessionKeyList, @RequestParam("message") String message);

    /**
     * 发布订阅的消息(群发)
     *
     * @param message 消息内容
     */
    @PostMapping(value = "/api/resource/message/publish/all")
    R<Void> publishAll(@RequestParam("message") String message);

}
